from flask import Flask
from config import Config
from app.extensions import db, migrate, cors
from app.routes.user import user_bp
from app.routes.property import property_bp

def create_app():
    app = Flask(__name__)
    # 加载配置
    app.config.from_object(Config)

    # 初始化插件
    db.init_app(app)
    migrate.init_app(app, db)
    cors.init_app(app)

    # 注册蓝图
    app.register_blueprint(user_bp, url_prefix="/api/user")
    app.register_blueprint(property_bp, url_prefix="/api/property")

    return app
